package com.ms.game.sendgift.db;

import java.util.Date;
import java.util.HashMap;

import javax.persistence.Entity;
import javax.persistence.Table;

import org.hibernate.annotations.Index;
import org.hibernate.annotations.Type;

import com.xpec.c4.db.model.basic.BasicGameModel;
import com.xpec.c4.db.util.LogDBUtils;


/**
 * 寄送禮物過程的通知
 */
@Entity
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@Table(name = "send_gift_notify_box")

public class SendGiftNotifyModel extends BasicGameModel{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8222779090409435445L;

	/**
	 * 寄送訂單ID
	 */
	private long sendOrderID;
	 
	/**
	 * 交易序號(顯示8碼)
	 */
	private String orderNumber;
	
	/**
	 * 交易ID(查log用)
	 */
	private String orderID;
	
	/**
	 * 計件者
	 */
	private String playerGUID;
	
	/**
	 * 計件者名稱
	 */
	private String playerName;
	
	/**
	 * 收件者
	 */
	private String targetGUID;
	
	/**
	 * 收件者名稱
	 */
	private String targetName;
	
	/**
	 * 金錢
	 */
	private long goldCoin;
	
	/**
	 * 手續費
	 */
	private long serviceCharge;
	
	/**
	 * 物品<br>
	 * key: 道具序號<br>
	 * value: 數量 (always 0, 無作用)
	 */
	private HashMap<String,Integer> items;
	
	/**
	 * 交易階段<br>
	 * 1 → 送出待接收<br>
	 * 2 → 接收待送出者確認<br>
	 * 3 → 送出者確認完成，交易完成<br>
	 */
	private int stage;
	
	/**
	 * 交易時間
	 */
	private Date createTime;
	
	/**
	 * 答覆時間
	 */
	private Date answerTime;
	
	/**
	 * 完成時間
	 */
	private Date finishTime;
	
	/**
	 * 收的人取走的時間
	 */
	private Date finalTakenTime;
	
	/**
	 * 過期時間
	 */
	private Date overTime;
	
	/**
	 * 退回的時間
	 */
	private Date sendBackTime;
	
	/**
	 * 是否已結束
	 */
	private boolean isFinish;
	
	/**
	 * 對方頭像
	 */
	private String targetFacePhoto;

	/**
	 * 寄送者頭像
	 */
	private String senderFacePhoto;
	
	/**
	 * 是否已拿取物品(?)   
	 * 20160415 sean 上面那個似乎怪怪的 taken似乎是用在判斷是否是最後一個階段
	 */
	private boolean isTaken;
	
	
	/**
	 * 訂單結束時間 (確認送出 或是取消)
	 */
	private Date orderFinishTime;
	
	public SendGiftNotifyModel(){
		super();
		
		sendOrderID = LogDBUtils.getRandomLong();
		String str = String.valueOf(sendOrderID);
		orderNumber = str.substring(str.length() - 8 , str.length());
		isFinish = false;
	}

	@Index(name = "index_orderID")
	public long getSendOrderID() {
		return sendOrderID;
	}

	public void setSendOrderID(long orderID) {
		this.sendOrderID = orderID;
	}

	public String getPlayerGUID() {
		return playerGUID;
	}

	public String getTargetGUID() {
		return targetGUID;
	}

	public long getGoldCoin() {
		return goldCoin;
	}

	@Type(type = "com.xpec.c4.db.usertype.MapStringIntegerToString")
	public HashMap<String, Integer> getItems() {
		return items;
	}

	public int getStage() {
		return stage;
	}

	public void setPlayerGUID(String playerGUID) {
		this.playerGUID = playerGUID;
	}

	public void setTargetGUID(String targetGUID) {
		this.targetGUID = targetGUID;
	}

	public void setGoldCoin(long goldCoin) {
		this.goldCoin = goldCoin;
	}

	public void setItems(HashMap<String, Integer> items) {
		this.items = items;
	}

	public void setStage(int stage) {
		this.stage = stage;
	}

	public String getPlayerName() {
		return playerName;
	}

	public String getTargetName() {
		return targetName;
	}

	public void setPlayerName(String playerName) {
		this.playerName = playerName;
	}

	public void setTargetName(String targetName) {
		this.targetName = targetName;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getOrderNumber() {
		return orderNumber;
	}

	public long getServiceCharge() {
		return serviceCharge;
	}

	public Date getAnswerTime() {
		return answerTime;
	}

	public Date getFinishTime() {
		return finishTime;
	}

	public Date getFinalTakenTime() {
		return finalTakenTime;
	}

	public void setFinalTakenTime(Date finalTakenTime) {
		this.finalTakenTime = finalTakenTime;
	}

	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}

	public void setServiceCharge(long serviceCharge) {
		this.serviceCharge = serviceCharge;
	}

	public void setAnswerTime(Date answerTime) {
		this.answerTime = answerTime;
	}

	public void setFinishTime(Date finishTime) {
		this.finishTime = finishTime;
	}

	public boolean isFinish() {
		return isFinish;
	}

	public void setFinish(boolean isFinish) {
		this.isFinish = isFinish;
	}
	
	public String getOrderID() {
		return orderID;
	}

	public void setOrderID(String orderID) {
		this.orderID = orderID;
	}

	public boolean isTaken() {
		return isTaken;
	}

	public void setTaken(boolean isTaken) {
		this.isTaken = isTaken;
	}

	public Date getOverTime() {
		return overTime;
	}

	public void setOverTime(Date overTime) {
		this.overTime = overTime;
	}
	
	public Date getSendBackTime() {
		return sendBackTime;
	}

	public void setSendBackTime(Date sendBackTime) {
		this.sendBackTime = sendBackTime;
	}

	public String getTargetFacePhoto() {
		return targetFacePhoto;
	}

	public void setTargetFacePhoto(String targetFacePhoto) {
		this.targetFacePhoto = targetFacePhoto;
	}
	
	public String getSenderFacePhoto() {
		return senderFacePhoto;
	}

	public void setSenderFacePhoto(String senderFacePhoto) {
		this.senderFacePhoto = senderFacePhoto;
	}

	public Date getOrderFinishTime() {
		return orderFinishTime;
	}

	public void setOrderFinishTime(Date orderFinishTime) {
		this.orderFinishTime = orderFinishTime;
	}
}
